﻿
function ClientDoSimpleSearch(belongSite) {
    Keyword = document.getElementById("txtSearchKeyword").value;
    Url = Portal.CDSP.FMenuWP.GetResultSearchUrl(belongSite, Keyword).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_self");
}


function ClientDoAdvSearch(belongSite, TabModuleId) {

        Keyword = document.getElementById("keyword").value;
        GroupNewsIndex=document.getElementById("drpSelectGroupNews").selectedIndex;
        GroupNewsId=document.getElementById("drpSelectGroupNews").options[GroupNewsIndex].value;
        GroupNewsItemIndex=document.getElementById("drpSelectGroupNewsItem").selectedIndex;
        GroupNewsItemId = document.getElementById("drpSelectGroupNewsItem").options[GroupNewsItemIndex].value;

        fromDate = document.getElementById("datefrom").value;
        toDate = document.getElementById("dateto").value;
        ps = null;
        
        rValue = Portal.CDSP.FSearchWP.GetHtml(belongSite, TabModuleId, Keyword, GroupNewsItemId, fromDate, toDate, 0, "JumpPageSearchAdvResult",ps).value;
        document.getElementById("ResultSearchContent").innerHTML = rValue;
}



function JumpPageSearchAdvResult(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    document.getElementById("divProcessingSearchResult").innerHTML = Portal.CDSP.FSearchWP.GetProcessingText().value;
    setTimeout("RealJumpPageSearchAdvResult('" + TabModuleId + "','" + MaxItems + "',20, 10, '" + CurrentPage + "', 'RealJumpPageSearchAdvResult')", 10);
}
function RealJumpPageSearchAdvResult(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    PageIndex = CurrentPage;

    belongSite = document.getElementById("txtBelongSite").value;
    Keyword = document.getElementById("keyword").value;
    GroupNewsIndex = document.getElementById("drpSelectGroupNews").selectedIndex;
    GroupNewsId = document.getElementById("drpSelectGroupNews").options[GroupNewsIndex].value;
    GroupNewsItemIndex = document.getElementById("drpSelectGroupNewsItem").selectedIndex;
    GroupNewsItemId = document.getElementById("drpSelectGroupNewsItem").options[GroupNewsItemIndex].value;

    fromDate = document.getElementById("datefrom").value;
    toDate = document.getElementById("dateto").value;
    ps = null;

    retValue = Portal.CDSP.FSearchWP.GetHtml(belongSite, TabModuleId, Keyword, GroupNewsItemId, fromDate, toDate, CurrentPage, JumpJavaScript, ps).value;
    //retValue = Portal.CDSP.FSearchWP.GetHtml(WebpartId, LocationId, Keyword, HomeTown, Age, Indent, Case, CurrentPage, JumpJavaScript, ps, rValue).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }

    document.getElementById("divProcessingSearchResult").innerHTML = "";
    document.getElementById("ResultSearchContent").innerHTML = retValue;
}



function ClientDoSimpleSearch1(belongSite) {
    var Keyword;
    Keyword = document.getElementById("txtSearchKeyword1").value;
    Url = Portal.CDSP.FResultSearch.GetResultSearchUrl(belongSite, Keyword).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_self");
}


function KeyPressForSearch(myfield, e, belongSite) {
    var keycode;
    if (myfield.event) keycode = myfield.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode == 13) {
        Keyword = document.getElementById("txtSearchKeyword").value;
        ClientDoSimpleSearch(belongSite);
        return false;
    }
    else {
        return true;
    }
}

function KeyPressForSearch1(myfield, e, belongSite) {
    var keycode;
    if (myfield.event) keycode = myfield.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode == 13) {
        Keyword = document.getElementById("txtSearchKeyword").value;
        ClientDoSimpleSearch1(belongSite);
        return false;
    }
    else {
        return true;
    }
}


     function ClientDetectGroupNewsItem()
{
         GroupNewsIndex=document.getElementById("drpSelectGroupNews").selectedIndex;
         GroupNewsId=document.getElementById("drpSelectGroupNews").options[GroupNewsIndex].value;
         ActiveGroupNewsItemId=document.getElementById("txtActiveGroupNewsItemId").value;
         rValue = Portal.CDSP.FSearchWP.BuildGroupNewsItem(GroupNewsId, ActiveGroupNewsItemId).value;
         document.getElementById("divGroupNewsItem").innerHTML=rValue;
     }
            